/*
 * To find maximum and minimum
 * in an array
 */

# include <IOSTREAM.H>
# include <CONIO.H>

class MaxMin {
  int a[100];
  int size, index, max, min;
public:
  void getArray();
  void printMaxMin();
};

void MaxMin :: getArray() {
  cout << "Enter the size of Array (less than 100): ";
  cin >> size;
  while(size < 1 || size > 100) {
    cout << "Array size can be any number between 1 and 100! Try Again: ";
    cin >> size;
  }
  for(index = 0; index < size; index++) {
    cout << "Enter " << (index+1) << "th element: ";
    cin >> a[index];
  }
}

void MaxMin :: printMaxMin() {
  max, min = a[0];
  for(index = 0; index < size; index++) {
    if(a[index] > max) {
      max = a[index];
    }
    if (a[index] < min) {
      min = a[index];
    }
  }
  cout << "Maximum is " << max << "\n";
  cout << "Minimum is " << min;
}

void main () {
  clrscr();
  MaxMin mm;
  mm.getArray();
  mm.printMaxMin();
  getch();
}